package com.ruoyi.web.controller.shortplay;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shortplay.domain.YoutobeDateOpera;
import com.ruoyi.shortplay.service.IYoutobeDateOperaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 每日操作Controller
 *
 * @author ruoyi
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/shortplay/opera")
public class YoutobeDateOperaController extends BaseController {

    @Autowired
    private IYoutobeDateOperaService youtobeDateOperaService;

    /**
     * 查询每日操作列表 有用户权限
     */
    @GetMapping("/list")
    public TableDataInfo list(YoutobeDateOpera youtobeDateOpera) {
        startPage();
        List<YoutobeDateOpera> list = youtobeDateOperaService.selectYoutobeDateOperaList(youtobeDateOpera,getUserId());
        return getDataTable(list);
    }

    /**
     * 导出每日操作列表
     */
    @Log(title = "每日操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YoutobeDateOpera youtobeDateOpera) {
        List<YoutobeDateOpera> list = youtobeDateOperaService.selectYoutobeDateOperaList(youtobeDateOpera, getUserId());
        ExcelUtil<YoutobeDateOpera> util = new ExcelUtil<YoutobeDateOpera>(YoutobeDateOpera.class);
        util.exportExcel(response, list, "每日操作数据");
    }

    /**
     * 获取每日操作详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(youtobeDateOperaService.selectYoutobeDateOperaById(id));
    }

    /**
     * 新增每日操作
     */
    @Log(title = "每日操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YoutobeDateOpera youtobeDateOpera) {
        return toAjax(youtobeDateOperaService.insertYoutobeDateOpera(youtobeDateOpera));
    }

    /**
     * 修改每日操作
     */
    @Log(title = "每日操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YoutobeDateOpera youtobeDateOpera) {
        return youtobeDateOperaService.updateYoutobeDateOpera(youtobeDateOpera);
    }

    /**
     * 删除每日操作
     */
    @Log(title = "每日操作", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(youtobeDateOperaService.deleteYoutobeDateOperaByIds(ids));
    }
}
